********************************************************
********************************************************
**********Claims in VIII. Multiple Testing**************
********************************************************
********************************************************

clear all
set mem 150m
set more off

use "/Users/gwf25/Dropbox/research/religion/final code/religion_all.dta"

//  Begin definition of variables

***Drop subjects who thought the experiment was about religion
gen id = _n
drop if id == 98 | id == 176 | id == 194 | id == 383

***Drop subjects who incorrectly completed the priming task. This includes subjects who leave more than half the responses blank. The following subjects
***all left at least questions #2-#7 blank in the sentence unscrambling task. 
drop if id==7 | id==719 | id==740 | id==762 | id==940

***An error led to some subjects seeing both the control and religion salient sentence unscrambling tasks. Here, we drop those subjects.
drop if prime_diff == 1

***"skipped" is a dummy variable for whether subjects skip the question that asks their religion. If they skip this question, we drop them from the sample 
***and if not, we assign a dummy variable to indicate the treatment group (religion salient or control) that subject belongs to.
gen skipped=0
replace skipped=1 if  s10q15==""
gen treatR=.
replace treatR=religion if skipped==0
drop if skipped==1

***Define religion
gen relig=.

***Note: 1 = protestant or other christian, 2 = catholic, 3 = jewish, 4 = agnostic/atheist
replace relig=1 if (s10q15=="Christian - Other (please specify below)" | s10q15=="Christian - Protestant (please specify denomination below)")
replace relig=2 if s10q15=="Christian - Catholic"
replace relig=3 if s10q15=="Jewish (Orthodox/Reformed/etc.)" | s10q15=="Jewish (Orthodox/Reform/etc.)"
replace relig=4 if (s10q15=="Agnostic" | s10q15=="Atheist")

***Drop Mormon/Othodox Christians from the sample
drop if s10q15sp == "Greek Orthodox"
drop if s10q15sp == "Russian Othrodox"
drop if s10q15sp == "greek orthodox"
drop if s10q15sp == "Orthodox Christian"
drop if s10q15sp == "Greek Orthdox"
drop if s10q15sp == "christian orthodox"
drop if s10q15sp == "Greek Orthodox Christian"
drop if s10q15sp == "Russian orthodox"
drop if s10q15sp == "Church of Jesus Christ of Latter Day Saints"
drop if s10q15sp == "Greek Orthodox"

drop id
// End of variables



****Create dependent variables to run in F-test****


***Wageoffer
rename m wageoffer

***Slope from regression of work cost on wages
***Create the cost, cXXX, for providing a certain amount of effort at eXXX. A certain monetary cost is associated with each level of output. So, we have:
***[eXXX, cXXX] = [(1,$0.00),(2,$0.04),(3,$0.08),(4,$0.16),(5,$0.24),(6,$0.32),(7,$0.40),(8,$0.48),(9,$0.60),(10,$0.72)]
gen c000 = .
replace c000 = 0 if e000 == 1
replace c000 = .04 if e000 == 2
replace c000 = .08 if e000 == 3
replace c000 = .16 if e000 == 4
replace c000 = .24 if e000 == 5
replace c000 = .32 if e000 == 6
replace c000 = .40 if e000 == 7
replace c000 = .48 if e000 == 8
replace c000 = .60 if e000 == 9
replace c000 = .72 if e000 == 10

gen c050 = .
replace c050 = 0 if e050 == 1
replace c050 = .04 if e050 == 2
replace c050 = .08 if e050 == 3
replace c050 = .16 if e050 == 4
replace c050 = .24 if e050 == 5
replace c050 = .32 if e050 == 6
replace c050 = .40 if e050 == 7
replace c050 = .48 if e050 == 8
replace c050 = .60 if e050 == 9
replace c050 = .72 if e050 == 10

gen c100 = .
replace c100 = 0 if e100 == 1
replace c100 = .04 if e100 == 2
replace c100 = .08 if e100 == 3
replace c100 = .16 if e100 == 4
replace c100 = .24 if e100 == 5
replace c100 = .32 if e100 == 6
replace c100 = .40 if e100 == 7
replace c100 = .48 if e100 == 8
replace c100 = .60 if e100 == 9
replace c100 = .72 if e100 == 10

gen c150 = .
replace c150 = 0 if e150 == 1
replace c150 = .04 if e150 == 2
replace c150 = .08 if e150 == 3
replace c150 = .16 if e150 == 4
replace c150 = .24 if e150 == 5
replace c150 = .32 if e150 == 6
replace c150 = .40 if e150 == 7
replace c150 = .48 if e150 == 8
replace c150 = .60 if e150 == 9
replace c150 = .72 if e150 == 10

gen c200 = .
replace c200 = 0 if e200 == 1
replace c200 = .04 if e200 == 2
replace c200 = .08 if e200 == 3
replace c200 = .16 if e200 == 4
replace c200 = .24 if e200 == 5
replace c200 = .32 if e200 == 6
replace c200 = .40 if e200 == 7
replace c200 = .48 if e200 == 8
replace c200 = .60 if e200 == 9
replace c200 = .72 if e200 == 10

gen c250 = .
replace c250 = 0 if e250 == 1
replace c250 = .04 if e250 == 2
replace c250 = .08 if e250 == 3
replace c250 = .16 if e250 == 4
replace c250 = .24 if e250 == 5
replace c250 = .32 if e250 == 6
replace c250 = .40 if e250 == 7
replace c250 = .48 if e250 == 8
replace c250 = .60 if e250 == 9
replace c250 = .72 if e250 == 10

gen c300 = .
replace c300 = 0 if e300 == 1
replace c300 = .04 if e300 == 2
replace c300 = .08 if e300 == 3
replace c300 = .16 if e300 == 4
replace c300 = .24 if e300 == 5
replace c300 = .32 if e300 == 6
replace c300 = .40 if e300 == 7
replace c300 = .48 if e300 == 8
replace c300 = .60 if e300 == 9
replace c300 = .72 if e300 == 10

gen c350 = .
replace c350 = 0 if e350 == 1
replace c350 = .04 if e350 == 2
replace c350 = .08 if e350 == 3
replace c350 = .16 if e350 == 4
replace c350 = .24 if e350 == 5
replace c350 = .32 if e350 == 6
replace c350 = .40 if e350 == 7
replace c350 = .48 if e350 == 8
replace c350 = .60 if e350 == 9
replace c350 = .72 if e350 == 10

gen c400 = .
replace c400 = 0 if e400 == 1
replace c400 = .04 if e400 == 2
replace c400 = .08 if e400 == 3
replace c400 = .16 if e400 == 4
replace c400 = .24 if e400 == 5
replace c400 = .32 if e400 == 6
replace c400 = .40 if e400 == 7
replace c400 = .48 if e400 == 8
replace c400 = .60 if e400 == 9
replace c400 = .72 if e400 == 10

***Drop the highest effort amount
drop c400

***In order to properly reshape the data, we must rename the effort and cost of effort at $0 and $0.50
rename e000 e0
rename e050 e50
rename c000 c0
rename c050 c50

***Create the corresponding wages for each effort choice
gen w0 = 0
gen w50 = .5
gen w100 = 1
gen w150 = 1.5
gen w200 = 2
gen w250 = 2.5
gen w300 = 3
gen w350 = 3.5

***Create the estimated regression parameter where beta=reciprocity
gen beta=.

gen id = _n

***Reshape the data so that we can regress cost of effort on all possible wages, by subject
reshape long c, i(id) j(w)

***Loop through all subjects and regress the effort on wage by each subject and save values of regression
***Note that some subjects did not do this section so we exclude them here. Only subjects numbered 263 through 689 did the gift exchange task.
quiet forvalues x = 263/689 {
reg c w if id ==`x'
replace beta=_b[w] if id ==`x'
}

***Reshape the data to its original form
reshape wide c, i(id) j(w)

***Public Good Contribution
rename s6 contribute

***Amount Given Away in Dictator Game
rename s5 giveaway

***Discount Rate

***Create the upper limit of the discount rate.
//gen r1=.
//replace r1= ln(ln(10.10/10)) if s2q1==1
//gen r2=.
//replace r2= ln(ln(10.25/10)) if s2q2==1
//gen r3=.
//replace r3= ln(ln(10.50/10)) if s2q3==1
//gen r4=.
//replace r4= ln(ln(10.75/10)) if s2q4==1
//gen r5=.
//replace r5= ln(ln(11/10)) if s2q5==1
//gen r6=.
//replace r6= ln(ln(11.25/10)) if s2q6==1
//gen r7=.
//replace r7= ln(ln(11.50/10)) if s2q7==1
//gen r8=.
//replace r8= ln(ln(12/10)) if s2q8==1
//gen r9=.
//replace r9= ln(ln(12.50/10)) if s2q9==1
//gen r10=.
//replace r10= ln(ln(13/10)) if s2q10==1
//gen r11=.
//replace r11= ln(ln(14/10)) if s2q11==1
//gen r12=.
//replace r12= ln(ln(15/10)) if s2q12==1

***Fill in the upper limit, rounding to 7 decimal places for now vs. 1 week choices.
gen r1=.
replace r1= -4.6101495 if s2q1==1
gen r2=.
replace r2= -3.7012512 if s2q2==1
gen r3=.
replace r3= -3.0202265 if s2q3==1
gen r4=.
replace r4= -2.6266454 if s2q4==1
gen r5=.
replace r5= -2.3506187 if s2q5==1
gen r6=.
replace r6= -2.1389110  if s2q6==1
gen r7=.
replace r7= -1.9678147 if s2q7==1
gen r8=.
replace r8= -1.7019834 if s2q8==1
gen r9=.
replace r9= -1.4999400 if s2q9==1
gen r10=.
replace r10= -1.3380214 if s2q10==1
gen r11=.
replace r11= -1.0892396 if s2q11==1
gen r12=.
replace r12= -0.9027205 if s2q12==1

***Choose the upper limit for the first time the subject makes the patient choice in the now vs. 1 week section.
gen reservationr1= min(r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12)

***Note that the number of missing observations for s2q1 through s2q24 (for those subjects who completed participated in the time section) is always zero.

***Fill in the upper limit, rounding to 7 decimal places for 1 week vs. 2 week choices.
gen r13=.
replace r13=-4.6101495 if s2q13==1
gen r14=.
replace r14= -3.7012512 if s2q14==1
gen r15=.
replace r15= -3.0202265 if s2q15==1
gen r16=.
replace r16= -2.6266454 if s2q16==1
gen r17=.
replace r17= -2.3506187 if s2q17==1
gen r18=.
replace r18= -2.1389110 if s2q18==1
gen r19=.
replace r19= -1.9678147 if s2q19==1
gen r20=.
replace r20= -1.7019834 if s2q20==1
gen r21=.
replace r21= -1.4999400 if s2q21==1
gen r22=.
replace r22= -1.3380214 if s2q22==1
gen r23=.
replace r23= -1.0892396 if s2q23==1
gen r24=.
replace r24= -0.9027205 if s2q24==1

***Choose the upper limit for the first time the subject makes the patient choice in the 1 week vs. 2 week section.
gen reservationr2=min(r13,r14,r15,r16,r17,r18,r19,r20,r21,r22,r23, r24)

***Each subject has an upper limit for the discount rate in now vs. 1 week and an upper limit for the discount rate in 1 week vs. two weeks. Rename these rateu_1 and rateu_2, respectively.
rename reservationr1 rateu_1
rename reservationr2 rateu_2
***Create a corresponding lower limit for each discount rate.
gen ratel_1=. 
gen ratel_2=.

***Fill in the values for the lower limit of the discount rate.
***Note that log(x) returns the natural log of ln(x) 
//replace ratel=. if rate==log(log(10.10/10))
//replace ratel= log(log(10.10/10)) if rate==log(log(10.25/10))
//replace ratel= log(log(10.25/10)) if rate==log(log(10.5/10))
//replace ratel= log(log(10.5/10)) if rate==log(log(10.75/10))
//replace ratel= log(log(10.75/10)) if rate==log(log(11/10))
//replace ratel= log(log(11/10)) if rate==log(log(11.25/10))
//replace ratel= log(log(11.25/10)) if rate==log(log(11.50/10))
//replace ratel= log(log(11.50/10)) if rate==log(log(12/10))
//replace ratel= log(log(12/10)) if rate==log(log(12.5/10))
//replace ratel= log(log(12.5/10)) if rate==log(log(13/10))
//replace ratel= log(log(13/10)) if rate==log(log(14/10))
//replace ratel= log(log(14/10)) if rate==log(log(15/10))
//replace ratel= log(log(15/10)) if rate==.

***Fill in the values for the lower limit of the discount rate for now vs. 1 week. This only assigns a value to those who took part in this section.
replace ratel_1=. if rateu_1 < -4.61 & s2q1 ~= .
replace ratel_1= -4.6101494 if rateu_1 < -3.7 & rateu_1 > -4.61  & s2q1 ~= .
replace ratel_1= -3.7012513 if rateu_1 < -3.02 & rateu_1 > -3.7  & s2q1 ~= .
replace ratel_1= -3.0202265 if rateu_1 < -2.62 & rateu_1 > -3.02 & s2q1 ~= .
replace ratel_1= -2.6266454 if rateu_1 < -2.35 & rateu_1 > -2.62 & s2q1 ~= .
replace ratel_1= -2.350618  if rateu_1 < -2.13 & rateu_1 > -2.35 & s2q1 ~= .
replace ratel_1= -2.1389110  if rateu_1 < -1.96 & rateu_1 > -2.13 & s2q1 ~= .
replace ratel_1= -1.9678147  if rateu_1 < -1.70 & rateu_1 > -1.96 & s2q1 ~= .
replace ratel_1= -1.7019834  if rateu_1 < -1.49 & rateu_1 > -1.70 & s2q1 ~= .
replace ratel_1= -1.4999400  if rateu_1 < -1.33 & rateu_1 > -1.49 & s2q1 ~= .
replace ratel_1= -1.3380214  if rateu_1 < -1.08 & rateu_1 > -1.33 & s2q1 ~= .
replace ratel_1= -1.0892396  if rateu_1 < -0.90 & rateu_1 > -1.08 & s2q1 ~= .
replace ratel_1= -0.9027205 if rateu_1 ==. & s2q1 ~= .

***Fill in the values for the lower limit of the discount rate for 1 week vs. 2 week. This only assigns a value to those who took part in this section.
replace ratel_2=. if rateu_2 < -4.61 & s2q1 ~= .
replace ratel_2= -4.6101494 if rateu_2 < -3.7 & rateu_2 > -4.61 & s2q1 ~= .
replace ratel_2= -3.7012513 if rateu_2 < -3.02 & rateu_2 > -3.7 & s2q1 ~= .
replace ratel_2= -3.0202265 if rateu_2 < -2.62 & rateu_2 > -3.02 & s2q1 ~= .
replace ratel_2= -2.6266454 if rateu_2 < -2.35 & rateu_2 > -2.62 & s2q1 ~= .
replace ratel_2= -2.350618  if rateu_2 < -2.13 & rateu_2 > -2.35 & s2q1 ~= .
replace ratel_2= -2.1389110  if rateu_2 < -1.96 & rateu_2 > -2.13 & s2q1 ~= .
replace ratel_2= -1.9678147  if rateu_2 < -1.70 & rateu_2 > -1.96 & s2q1 ~= .
replace ratel_2= -1.7019834  if rateu_2 < -1.49 & rateu_2 > -1.70 & s2q1 ~= .
replace ratel_2= -1.4999400  if rateu_2 < -1.33 & rateu_2 > -1.49 & s2q1 ~= .
replace ratel_2= -1.3380214  if rateu_2 < -1.08 & rateu_2 > -1.33 & s2q1 ~= .
replace ratel_2= -1.0892396  if rateu_2 < -0.90 & rateu_2 > -1.08 & s2q1 ~= .
replace ratel_2= -0.9027205 if rateu_2 ==. & s2q1 ~= .




***Risk Aversion

***Generate upper limit for risk with small amounts
gen risk1=.
replace risk1=(1.6*0.5-1) if s3q1==1
gen risk2=.
replace risk2=(2*0.5-1) if s3q2==1
gen risk3=.
replace risk3=(2.4*0.5-1) if s3q3==1
gen risk4=.
replace risk4=(2.8*0.5-1) if s3q4==1
gen risk5=.
replace risk5=(3.2*0.5-1) if s3q5==1
gen risk6=.
replace risk6=(3.6*0.5-1) if s3q6==1

***Choose the upper limit for the first time a subject chooses the risky asset with small amounts.
gen reservationrisk1= min(risk1,risk2,risk3,risk4,risk5,risk6)

***Generate upper limit for risk with large amounts
gen risk7=.
replace risk7=(160*0.5-100)/100 if s4q1==1
gen risk8=.
replace risk8=(200*0.5-100)/100 if s4q2==1
gen risk9=.
replace risk9=(240*0.5-100)/100 if s4q3==1
gen risk10=.
replace risk10=(280*0.5-100)/100 if s4q4==1
gen risk11=.
replace risk11=(320*0.5-100)/100 if s4q5==1
gen risk12=.
replace risk12=(360*0.5-100)/100 if s4q6==1

***Choose the upper limit for the first time a subject chooses the risky asset with large amounts.
gen reservationrisk2= min(risk7,risk8,risk9,risk10,risk11,risk12)

***risku_1 and risku_2 are the upper limits for risky choices with small and large stakes, respectively.
rename reservationrisk1 risku_1
rename reservationrisk2 risku_2
***Create variables for the lower limits.
gen riskl_1=.
gen riskl_2=.

***Assign values for the lower limit in small stakes. Only those who took participated in this section are assigned values.
replace riskl_1=. if risku_1 < -.2  & s4q1 ~= .
replace riskl_1=(1.6*0.5-1) if risku_1 == 0 & s4q1 ~= .
replace riskl_1=(2*0.5-1) if risku_1 > .1 & risku_1 < .3 & s4q1 ~= .
replace riskl_1=(2.4*0.5-1) if risku_1 > .3 & risku_1 < .5 & s4q1 ~= .
replace riskl_1=(2.8*0.5-1) if risku_1 > .5 & risku_1 < .7 & s4q1 ~= .
replace riskl_1=(3.2*0.5-1) if risku_1 > .7 & risku_1 < .9 & s4q1 ~= .
replace riskl_1=(3.6*0.5-1) if risku_1 == . & s4q1 ~= .

***Assign values for the lower limit in large stakes. Only those who took participated in this section are assigned values.
replace riskl_2=. if risku_2 < -.2  & s4q1 ~= .
replace riskl_2=(1.6*0.5-1) if risku_2 == 0 & s4q1 ~= .
replace riskl_2=(2*0.5-1) if risku_2 > .1 & risku_2 < .3 & s4q1 ~= .
replace riskl_2=(2.4*0.5-1) if risku_2 > .3 & risku_2 < .5 & s4q1 ~= .
replace riskl_2=(2.8*0.5-1) if risku_2 > .5 & risku_2 < .7 & s4q1 ~= .
replace riskl_2=(3.2*0.5-1) if risku_2 > .7 & risku_2 < .9 & s4q1 ~= .
replace riskl_2=(3.6*0.5-1) if risku_2 == . & s4q1 ~= .


***Anagrams Attempted
***The corresponding variable is named "anagramsattempted"

***Drop subjects who are not in our 4 religious groups
drop if relig == .

replace id = _n

***Create the dependent variables. When p_i = d_i, the data is point data. When p_i ~= d_i, the data is interval data (only discount rate and risk aversion)
rename contribute d1
gen p1 = d1
rename beta d2
gen p2 = d2
rename giveaway d3
gen p3 = d3
rename ratel_1 d4
rename rateu_1 p4
rename ratel_2 d5
rename rateu_2 p5
rename riskl_1 d6
rename risku_1 p6
rename riskl_2 d7
rename risku_2 p7
rename anagramsattempted d8
gen p8 = d8
*rename wageoffer d9
*gen p9 = d9
rename s6exp d9
gen p9 = d9

reshape long d p, i(id) j(section_num)

***Dummies for task type
gen u1 = 0 //contribute
replace u1 = 1 if section_num == 1 & d ~= .
gen u2 = 0 //beta
replace u2 = 1 if section_num == 2 & d ~= .
gen u3 = 0 //giveaway
replace u3 = 1 if section_num == 3 & d ~= .
gen u4 = 0 //TP
replace u4 = 1 if (section_num == 4 | section_num == 5) & (d ~= . | p ~= .)
gen u5 = 0 //RP
replace u5 = 1 if (section_num == 6 | section_num == 7) & (d ~= . | p ~= .)
gen u6 = 0 //AN
replace u6 = 1 if section_num == 8 & d ~= .
gen u7 = 0 //s6exp (public good expectation)
replace u7 = 1 if section_num == 9 & d ~= .

***Additional controls
gen onevstwo = 0
replace onevstwo = 1 if section_num == 5
gen largestakes = 0
replace largestakes = 1 if section_num == 7

***Treatment Dummies
gen treatRpg = 0
replace treatRpg = 1 if treatR == 1 & section_num == 1 & d ~= .
gen treatRge = 0
replace treatRge = 1 if treatR == 1 & section_num == 2 & d ~= .
gen treatRdg = 0
replace treatRdg = 1 if treatR == 1 & section_num == 3 & d ~= .
gen treatRtp = 0
replace treatRtp = 1 if treatR == 1 & (section_num == 4 | section_num == 5) & (d ~= . | p ~= .)
gen treatRrp = 0
replace treatRrp = 1 if treatR == 1 & (section_num == 6 | section_num == 7) & (d ~= . | p ~= .)
gen treatRan = 0
replace treatRan = 1 if treatR == 1 & section_num == 8 & d ~= .
gen treatRtr = 0
replace treatRtr = 1 if treatR == 1 & section_num == 9 & d ~= .

***Religion interactions
gen prot = 0
replace prot = 1 if relig == 1
gen prot1 = prot * u1
gen prot2 = prot * u2
gen prot3 = prot * u3
gen prot4 = prot * u4
gen prot5 = prot * u5
gen prot6 = prot * u6
gen prot7 = prot * u7
gen prot8 = prot * onevstwo
gen prot9 = prot * largestakes
gen prot10 = prot * treatRpg
gen prot11 = prot * treatRge 
gen prot12 = prot * treatRdg 
gen prot13 = prot * treatRtp 
gen prot14 = prot * treatRrp 
gen prot15 = prot * treatRan 
gen prot16 = prot * treatRtr

gen cath = 0
replace cath = 1 if relig == 2
gen cath1 = cath * u1
gen cath2 = cath * u2
gen cath3 = cath * u3
gen cath4 = cath * u4
gen cath5 = cath * u5
gen cath6 = cath * u6
gen cath7 = cath * u7
gen cath8 = cath * onevstwo
gen cath9 = cath * largestakes
gen cath10 = cath * treatRpg
gen cath11 = cath * treatRge 
gen cath12 = cath * treatRdg 
gen cath13 = cath * treatRtp 
gen cath14 = cath * treatRrp 
gen cath15 = cath * treatRan 
gen cath16 = cath * treatRtr

gen jewi = 0
replace jewi = 1 if relig == 3
gen jewi1 = jewi * u1
gen jewi2 = jewi * u2
gen jewi3 = jewi * u3
gen jewi4 = jewi * u4
gen jewi5 = jewi * u5
gen jewi6 = jewi * u6
gen jewi7 = jewi * u7
gen jewi8 = jewi * onevstwo
gen jewi9 = jewi * largestakes
gen jewi10 = jewi * treatRpg
gen jewi11 = jewi * treatRge 
gen jewi12 = jewi * treatRdg 
gen jewi13 = jewi * treatRtp 
gen jewi14 = jewi * treatRrp 
gen jewi15 = jewi * treatRan
gen jewi16 = jewi * treatRtr

gen atag = 0
replace atag = 1 if relig == 4
gen atag1 = atag * u1
gen atag2 = atag * u2
gen atag3 = atag * u3
gen atag4 = atag * u4
gen atag5 = atag * u5
gen atag6 = atag * u6
gen atag7 = atag * u7
gen atag8 = atag * onevstwo
gen atag9 = atag * largestakes
gen atag10 = atag * treatRpg
gen atag11 = atag * treatRge 
gen atag12 = atag * treatRdg 
gen atag13 = atag * treatRtp 
gen atag14 = atag * treatRrp 
gen atag15 = atag * treatRan
gen atag16 = atag * treatRtr

intreg d p prot1 prot2 prot3 prot4 prot5 prot6 prot7 prot8 prot9 prot10 prot11 prot12 prot13 prot14 prot15 prot16 cath1 cath2 cath3 cath4 cath5 cath6 cath7 cath8 cath9 cath10 cath11 cath12 cath13 cath14 cath15 cath16 jewi1 jewi2 jewi3 jewi4 jewi5 jewi6 jewi7 jewi8 jewi9 jewi10 jewi11 jewi12 jewi13 jewi14 jewi15 jewi16 atag1 atag2 atag3 atag4 atag5 atag6 atag7 atag8 atag9 atag10 atag11 atag12 atag13 atag14 atag15 atag16 , noconstant het(prot1 prot2 prot3 prot4 prot5 prot6 prot7 cath1 cath2 cath3 cath4 cath5 cath6 cath7 jewi1 jewi2 jewi3 jewi4 jewi5 jewi6 jewi7 atag1 atag2 atag3 atag4 atag5 atag6 atag7) cluster(id)

test (prot10 = 0) (prot11 = 0) (prot12 = 0) (prot13 = 0) (prot14 = 0) (prot15 = 0) (prot16 = 0) (cath10 = 0) (cath11 = 0) (cath12 = 0) (cath13 = 0) (cath14 = 0) (cath15 = 0) (cath16 = 0) (jewi10 = 0) (jewi11 = 0) (jewi12 = 0) (jewi13 = 0) (jewi14 = 0) (jewi15 = 0) (jewi16 = 0) (atag10 = 0) (atag11 = 0) (atag12 = 0) (atag13 = 0) (atag14 = 0) (atag15 = 0) (atag16 = 0)




*including manager's wage offer
clear all
set mem 150m
set more off

use "/Users/gwf25/Dropbox/research/religion/final code/religion_all.dta"

//  Begin definition of variables

***Drop subjects who thought the experiment was about religion
gen id = _n
drop if id == 98 | id == 176 | id == 194 | id == 383

***Drop subjects who incorrectly completed the priming task. This includes subjects who leave more than half the responses blank. The following subjects
***all left at least questions #2-#7 blank in the sentence unscrambling task. 
drop if id==7 | id==719 | id==740 | id==762 | id==940

***An error led to some subjects seeing both the control and religion salient sentence unscrambling tasks. Here, we drop those subjects.
drop if prime_diff == 1

***"skipped" is a dummy variable for whether subjects skip the question that asks their religion. If they skip this question, we drop them from the sample 
***and if not, we assign a dummy variable to indicate the treatment group (religion salient or control) that subject belongs to.
gen skipped=0
replace skipped=1 if  s10q15==""
gen treatR=.
replace treatR=religion if skipped==0
drop if skipped==1

***Define religion
gen relig=.

***Note: 1 = protestant or other christian, 2 = catholic, 3 = jewish, 4 = agnostic/atheist
replace relig=1 if (s10q15=="Christian - Other (please specify below)" | s10q15=="Christian - Protestant (please specify denomination below)")
replace relig=2 if s10q15=="Christian - Catholic"
replace relig=3 if s10q15=="Jewish (Orthodox/Reformed/etc.)" | s10q15=="Jewish (Orthodox/Reform/etc.)"
replace relig=4 if (s10q15=="Agnostic" | s10q15=="Atheist")

***Drop Mormon/Othodox Christians from the sample
drop if s10q15sp == "Greek Orthodox"
drop if s10q15sp == "Russian Othrodox"
drop if s10q15sp == "greek orthodox"
drop if s10q15sp == "Orthodox Christian"
drop if s10q15sp == "Greek Orthdox"
drop if s10q15sp == "christian orthodox"
drop if s10q15sp == "Greek Orthodox Christian"
drop if s10q15sp == "Russian orthodox"
drop if s10q15sp == "Church of Jesus Christ of Latter Day Saints"
drop if s10q15sp == "Greek Orthodox"

drop id
// End of variables

****Create dependent variables to run in F-test****


***Wageoffer
rename m wageoffer

***Slope from regression of work cost on wages
***Create the cost, cXXX, for providing a certain amount of effort at eXXX. A certain monetary cost is associated with each level of output. So, we have:
***[eXXX, cXXX] = [(1,$0.00),(2,$0.04),(3,$0.08),(4,$0.16),(5,$0.24),(6,$0.32),(7,$0.40),(8,$0.48),(9,$0.60),(10,$0.72)]
gen c000 = .
replace c000 = 0 if e000 == 1
replace c000 = .04 if e000 == 2
replace c000 = .08 if e000 == 3
replace c000 = .16 if e000 == 4
replace c000 = .24 if e000 == 5
replace c000 = .32 if e000 == 6
replace c000 = .40 if e000 == 7
replace c000 = .48 if e000 == 8
replace c000 = .60 if e000 == 9
replace c000 = .72 if e000 == 10

gen c050 = .
replace c050 = 0 if e050 == 1
replace c050 = .04 if e050 == 2
replace c050 = .08 if e050 == 3
replace c050 = .16 if e050 == 4
replace c050 = .24 if e050 == 5
replace c050 = .32 if e050 == 6
replace c050 = .40 if e050 == 7
replace c050 = .48 if e050 == 8
replace c050 = .60 if e050 == 9
replace c050 = .72 if e050 == 10

gen c100 = .
replace c100 = 0 if e100 == 1
replace c100 = .04 if e100 == 2
replace c100 = .08 if e100 == 3
replace c100 = .16 if e100 == 4
replace c100 = .24 if e100 == 5
replace c100 = .32 if e100 == 6
replace c100 = .40 if e100 == 7
replace c100 = .48 if e100 == 8
replace c100 = .60 if e100 == 9
replace c100 = .72 if e100 == 10

gen c150 = .
replace c150 = 0 if e150 == 1
replace c150 = .04 if e150 == 2
replace c150 = .08 if e150 == 3
replace c150 = .16 if e150 == 4
replace c150 = .24 if e150 == 5
replace c150 = .32 if e150 == 6
replace c150 = .40 if e150 == 7
replace c150 = .48 if e150 == 8
replace c150 = .60 if e150 == 9
replace c150 = .72 if e150 == 10

gen c200 = .
replace c200 = 0 if e200 == 1
replace c200 = .04 if e200 == 2
replace c200 = .08 if e200 == 3
replace c200 = .16 if e200 == 4
replace c200 = .24 if e200 == 5
replace c200 = .32 if e200 == 6
replace c200 = .40 if e200 == 7
replace c200 = .48 if e200 == 8
replace c200 = .60 if e200 == 9
replace c200 = .72 if e200 == 10

gen c250 = .
replace c250 = 0 if e250 == 1
replace c250 = .04 if e250 == 2
replace c250 = .08 if e250 == 3
replace c250 = .16 if e250 == 4
replace c250 = .24 if e250 == 5
replace c250 = .32 if e250 == 6
replace c250 = .40 if e250 == 7
replace c250 = .48 if e250 == 8
replace c250 = .60 if e250 == 9
replace c250 = .72 if e250 == 10

gen c300 = .
replace c300 = 0 if e300 == 1
replace c300 = .04 if e300 == 2
replace c300 = .08 if e300 == 3
replace c300 = .16 if e300 == 4
replace c300 = .24 if e300 == 5
replace c300 = .32 if e300 == 6
replace c300 = .40 if e300 == 7
replace c300 = .48 if e300 == 8
replace c300 = .60 if e300 == 9
replace c300 = .72 if e300 == 10

gen c350 = .
replace c350 = 0 if e350 == 1
replace c350 = .04 if e350 == 2
replace c350 = .08 if e350 == 3
replace c350 = .16 if e350 == 4
replace c350 = .24 if e350 == 5
replace c350 = .32 if e350 == 6
replace c350 = .40 if e350 == 7
replace c350 = .48 if e350 == 8
replace c350 = .60 if e350 == 9
replace c350 = .72 if e350 == 10

gen c400 = .
replace c400 = 0 if e400 == 1
replace c400 = .04 if e400 == 2
replace c400 = .08 if e400 == 3
replace c400 = .16 if e400 == 4
replace c400 = .24 if e400 == 5
replace c400 = .32 if e400 == 6
replace c400 = .40 if e400 == 7
replace c400 = .48 if e400 == 8
replace c400 = .60 if e400 == 9
replace c400 = .72 if e400 == 10

***Drop the highest effort amount
drop c400

***In order to properly reshape the data, we must rename the effort and cost of effort at $0 and $0.50
rename e000 e0
rename e050 e50
rename c000 c0
rename c050 c50

***Create the corresponding wages for each effort choice
gen w0 = 0
gen w50 = .5
gen w100 = 1
gen w150 = 1.5
gen w200 = 2
gen w250 = 2.5
gen w300 = 3
gen w350 = 3.5

***Create the estimated regression parameter where beta=reciprocity
gen beta=.

gen id = _n

***Reshape the data so that we can regress cost of effort on all possible wages, by subject
reshape long c, i(id) j(w)

***Loop through all subjects and regress the effort on wage by each subject and save values of regression
***Note that some subjects did not do this section so we exclude them here. Only subjects numbered 263 through 689 did the gift exchange task.
quiet forvalues x = 263/689 {
reg c w if id ==`x'
replace beta=_b[w] if id ==`x'
}

***Reshape the data to its original form
reshape wide c, i(id) j(w)

***Public Good Contribution
rename s6 contribute

***Amount Given Away in Dictator Game
rename s5 giveaway

***Discount Rate

***Create the upper limit of the discount rate.
//gen r1=.
//replace r1= ln(ln(10.10/10)) if s2q1==1
//gen r2=.
//replace r2= ln(ln(10.25/10)) if s2q2==1
//gen r3=.
//replace r3= ln(ln(10.50/10)) if s2q3==1
//gen r4=.
//replace r4= ln(ln(10.75/10)) if s2q4==1
//gen r5=.
//replace r5= ln(ln(11/10)) if s2q5==1
//gen r6=.
//replace r6= ln(ln(11.25/10)) if s2q6==1
//gen r7=.
//replace r7= ln(ln(11.50/10)) if s2q7==1
//gen r8=.
//replace r8= ln(ln(12/10)) if s2q8==1
//gen r9=.
//replace r9= ln(ln(12.50/10)) if s2q9==1
//gen r10=.
//replace r10= ln(ln(13/10)) if s2q10==1
//gen r11=.
//replace r11= ln(ln(14/10)) if s2q11==1
//gen r12=.
//replace r12= ln(ln(15/10)) if s2q12==1

***Fill in the upper limit, rounding to 7 decimal places for now vs. 1 week choices.
gen r1=.
replace r1= -4.6101495 if s2q1==1
gen r2=.
replace r2= -3.7012512 if s2q2==1
gen r3=.
replace r3= -3.0202265 if s2q3==1
gen r4=.
replace r4= -2.6266454 if s2q4==1
gen r5=.
replace r5= -2.3506187 if s2q5==1
gen r6=.
replace r6= -2.1389110  if s2q6==1
gen r7=.
replace r7= -1.9678147 if s2q7==1
gen r8=.
replace r8= -1.7019834 if s2q8==1
gen r9=.
replace r9= -1.4999400 if s2q9==1
gen r10=.
replace r10= -1.3380214 if s2q10==1
gen r11=.
replace r11= -1.0892396 if s2q11==1
gen r12=.
replace r12= -0.9027205 if s2q12==1

***Choose the upper limit for the first time the subject makes the patient choice in the now vs. 1 week section.
gen reservationr1= min(r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12)

***Note that the number of missing observations for s2q1 through s2q24 (for those subjects who completed participated in the time section) is always zero.

***Fill in the upper limit, rounding to 7 decimal places for 1 week vs. 2 week choices.
gen r13=.
replace r13=-4.6101495 if s2q13==1
gen r14=.
replace r14= -3.7012512 if s2q14==1
gen r15=.
replace r15= -3.0202265 if s2q15==1
gen r16=.
replace r16= -2.6266454 if s2q16==1
gen r17=.
replace r17= -2.3506187 if s2q17==1
gen r18=.
replace r18= -2.1389110 if s2q18==1
gen r19=.
replace r19= -1.9678147 if s2q19==1
gen r20=.
replace r20= -1.7019834 if s2q20==1
gen r21=.
replace r21= -1.4999400 if s2q21==1
gen r22=.
replace r22= -1.3380214 if s2q22==1
gen r23=.
replace r23= -1.0892396 if s2q23==1
gen r24=.
replace r24= -0.9027205 if s2q24==1

***Choose the upper limit for the first time the subject makes the patient choice in the 1 week vs. 2 week section.
gen reservationr2=min(r13,r14,r15,r16,r17,r18,r19,r20,r21,r22,r23, r24)

***Each subject has an upper limit for the discount rate in now vs. 1 week and an upper limit for the discount rate in 1 week vs. two weeks. Rename these rateu_1 and rateu_2, respectively.
rename reservationr1 rateu_1
rename reservationr2 rateu_2
***Create a corresponding lower limit for each discount rate.
gen ratel_1=. 
gen ratel_2=.

***Fill in the values for the lower limit of the discount rate.
***Note that log(x) returns the natural log of ln(x) 
//replace ratel=. if rate==log(log(10.10/10))
//replace ratel= log(log(10.10/10)) if rate==log(log(10.25/10))
//replace ratel= log(log(10.25/10)) if rate==log(log(10.5/10))
//replace ratel= log(log(10.5/10)) if rate==log(log(10.75/10))
//replace ratel= log(log(10.75/10)) if rate==log(log(11/10))
//replace ratel= log(log(11/10)) if rate==log(log(11.25/10))
//replace ratel= log(log(11.25/10)) if rate==log(log(11.50/10))
//replace ratel= log(log(11.50/10)) if rate==log(log(12/10))
//replace ratel= log(log(12/10)) if rate==log(log(12.5/10))
//replace ratel= log(log(12.5/10)) if rate==log(log(13/10))
//replace ratel= log(log(13/10)) if rate==log(log(14/10))
//replace ratel= log(log(14/10)) if rate==log(log(15/10))
//replace ratel= log(log(15/10)) if rate==.

***Fill in the values for the lower limit of the discount rate for now vs. 1 week. This only assigns a value to those who took part in this section.
replace ratel_1=. if rateu_1 < -4.61 & s2q1 ~= .
replace ratel_1= -4.6101494 if rateu_1 < -3.7 & rateu_1 > -4.61  & s2q1 ~= .
replace ratel_1= -3.7012513 if rateu_1 < -3.02 & rateu_1 > -3.7  & s2q1 ~= .
replace ratel_1= -3.0202265 if rateu_1 < -2.62 & rateu_1 > -3.02 & s2q1 ~= .
replace ratel_1= -2.6266454 if rateu_1 < -2.35 & rateu_1 > -2.62 & s2q1 ~= .
replace ratel_1= -2.350618  if rateu_1 < -2.13 & rateu_1 > -2.35 & s2q1 ~= .
replace ratel_1= -2.1389110  if rateu_1 < -1.96 & rateu_1 > -2.13 & s2q1 ~= .
replace ratel_1= -1.9678147  if rateu_1 < -1.70 & rateu_1 > -1.96 & s2q1 ~= .
replace ratel_1= -1.7019834  if rateu_1 < -1.49 & rateu_1 > -1.70 & s2q1 ~= .
replace ratel_1= -1.4999400  if rateu_1 < -1.33 & rateu_1 > -1.49 & s2q1 ~= .
replace ratel_1= -1.3380214  if rateu_1 < -1.08 & rateu_1 > -1.33 & s2q1 ~= .
replace ratel_1= -1.0892396  if rateu_1 < -0.90 & rateu_1 > -1.08 & s2q1 ~= .
replace ratel_1= -0.9027205 if rateu_1 ==. & s2q1 ~= .

***Fill in the values for the lower limit of the discount rate for 1 week vs. 2 week. This only assigns a value to those who took part in this section.
replace ratel_2=. if rateu_2 < -4.61 & s2q1 ~= .
replace ratel_2= -4.6101494 if rateu_2 < -3.7 & rateu_2 > -4.61 & s2q1 ~= .
replace ratel_2= -3.7012513 if rateu_2 < -3.02 & rateu_2 > -3.7 & s2q1 ~= .
replace ratel_2= -3.0202265 if rateu_2 < -2.62 & rateu_2 > -3.02 & s2q1 ~= .
replace ratel_2= -2.6266454 if rateu_2 < -2.35 & rateu_2 > -2.62 & s2q1 ~= .
replace ratel_2= -2.350618  if rateu_2 < -2.13 & rateu_2 > -2.35 & s2q1 ~= .
replace ratel_2= -2.1389110  if rateu_2 < -1.96 & rateu_2 > -2.13 & s2q1 ~= .
replace ratel_2= -1.9678147  if rateu_2 < -1.70 & rateu_2 > -1.96 & s2q1 ~= .
replace ratel_2= -1.7019834  if rateu_2 < -1.49 & rateu_2 > -1.70 & s2q1 ~= .
replace ratel_2= -1.4999400  if rateu_2 < -1.33 & rateu_2 > -1.49 & s2q1 ~= .
replace ratel_2= -1.3380214  if rateu_2 < -1.08 & rateu_2 > -1.33 & s2q1 ~= .
replace ratel_2= -1.0892396  if rateu_2 < -0.90 & rateu_2 > -1.08 & s2q1 ~= .
replace ratel_2= -0.9027205 if rateu_2 ==. & s2q1 ~= .




***Risk Aversion

***Generate upper limit for risk with small amounts
gen risk1=.
replace risk1=(1.6*0.5-1) if s3q1==1
gen risk2=.
replace risk2=(2*0.5-1) if s3q2==1
gen risk3=.
replace risk3=(2.4*0.5-1) if s3q3==1
gen risk4=.
replace risk4=(2.8*0.5-1) if s3q4==1
gen risk5=.
replace risk5=(3.2*0.5-1) if s3q5==1
gen risk6=.
replace risk6=(3.6*0.5-1) if s3q6==1

***Choose the upper limit for the first time a subject chooses the risky asset with small amounts.
gen reservationrisk1= min(risk1,risk2,risk3,risk4,risk5,risk6)

***Generate upper limit for risk with large amounts
gen risk7=.
replace risk7=(160*0.5-100)/100 if s4q1==1
gen risk8=.
replace risk8=(200*0.5-100)/100 if s4q2==1
gen risk9=.
replace risk9=(240*0.5-100)/100 if s4q3==1
gen risk10=.
replace risk10=(280*0.5-100)/100 if s4q4==1
gen risk11=.
replace risk11=(320*0.5-100)/100 if s4q5==1
gen risk12=.
replace risk12=(360*0.5-100)/100 if s4q6==1

***Choose the upper limit for the first time a subject chooses the risky asset with large amounts.
gen reservationrisk2= min(risk7,risk8,risk9,risk10,risk11,risk12)

***risku_1 and risku_2 are the upper limits for risky choices with small and large stakes, respectively.
rename reservationrisk1 risku_1
rename reservationrisk2 risku_2
***Create variables for the lower limits.
gen riskl_1=.
gen riskl_2=.

***Assign values for the lower limit in small stakes. Only those who took participated in this section are assigned values.
replace riskl_1=. if risku_1 < -.2  & s4q1 ~= .
replace riskl_1=(1.6*0.5-1) if risku_1 == 0 & s4q1 ~= .
replace riskl_1=(2*0.5-1) if risku_1 > .1 & risku_1 < .3 & s4q1 ~= .
replace riskl_1=(2.4*0.5-1) if risku_1 > .3 & risku_1 < .5 & s4q1 ~= .
replace riskl_1=(2.8*0.5-1) if risku_1 > .5 & risku_1 < .7 & s4q1 ~= .
replace riskl_1=(3.2*0.5-1) if risku_1 > .7 & risku_1 < .9 & s4q1 ~= .
replace riskl_1=(3.6*0.5-1) if risku_1 == . & s4q1 ~= .

***Assign values for the lower limit in large stakes. Only those who took participated in this section are assigned values.
replace riskl_2=. if risku_2 < -.2  & s4q1 ~= .
replace riskl_2=(1.6*0.5-1) if risku_2 == 0 & s4q1 ~= .
replace riskl_2=(2*0.5-1) if risku_2 > .1 & risku_2 < .3 & s4q1 ~= .
replace riskl_2=(2.4*0.5-1) if risku_2 > .3 & risku_2 < .5 & s4q1 ~= .
replace riskl_2=(2.8*0.5-1) if risku_2 > .5 & risku_2 < .7 & s4q1 ~= .
replace riskl_2=(3.2*0.5-1) if risku_2 > .7 & risku_2 < .9 & s4q1 ~= .
replace riskl_2=(3.6*0.5-1) if risku_2 == . & s4q1 ~= .


***Anagrams Attempted
***The corresponding variable is named "anagramsattempted"

***Drop subjects who are not in our 4 religious groups
drop if relig == .

replace id = _n

***Create the dependent variables. When p_i = d_i, the data is point data. When p_i ~= d_i, the data is interval data (only discount rate and risk aversion)
rename contribute d1
gen p1 = d1
rename beta d2
gen p2 = d2
rename giveaway d3
gen p3 = d3
rename ratel_1 d4
rename rateu_1 p4
rename ratel_2 d5
rename rateu_2 p5
rename riskl_1 d6
rename risku_1 p6
rename riskl_2 d7
rename risku_2 p7
rename anagramsattempted d8
gen p8 = d8
rename s6exp d9
gen p9 = d9
rename wageoffer d10
gen p10 = d10

reshape long d p, i(id) j(section_num)

***Dummies for task type
gen u1 = 0 //contribute
replace u1 = 1 if section_num == 1 & d ~= .
gen u2 = 0 //beta
replace u2 = 1 if section_num == 2 & d ~= .
gen u3 = 0 //giveaway
replace u3 = 1 if section_num == 3 & d ~= .
gen u4 = 0 //TP
replace u4 = 1 if (section_num == 4 | section_num == 5) & (d ~= . | p ~= .)
gen u5 = 0 //RP
replace u5 = 1 if (section_num == 6 | section_num == 7) & (d ~= . | p ~= .)
gen u6 = 0 //AN
replace u6 = 1 if section_num == 8 & d ~= .
gen u7 = 0 //s6exp (public good expectation)
replace u7 = 1 if section_num == 9 & d ~= .
gen u8 = 0 //wageoffer
replace u8 = 1 if section_num == 10 & d ~= .

***Additional controls
gen onevstwo = 0
replace onevstwo = 1 if section_num == 5
gen largestakes = 0
replace largestakes = 1 if section_num == 7

***Treatment Dummies
gen treatRpg = 0
replace treatRpg = 1 if treatR == 1 & section_num == 1 & d ~= .
gen treatRge = 0
replace treatRge = 1 if treatR == 1 & section_num == 2 & d ~= .
gen treatRdg = 0
replace treatRdg = 1 if treatR == 1 & section_num == 3 & d ~= .
gen treatRtp = 0
replace treatRtp = 1 if treatR == 1 & (section_num == 4 | section_num == 5) & (d ~= . | p ~= .)
gen treatRrp = 0
replace treatRrp = 1 if treatR == 1 & (section_num == 6 | section_num == 7) & (d ~= . | p ~= .)
gen treatRan = 0
replace treatRan = 1 if treatR == 1 & section_num == 8 & d ~= .
gen treatRtr = 0
replace treatRtr = 1 if treatR == 1 & section_num == 9 & d ~= .
gen treatRwa = 0
replace treatRwa = 1 if treatR == 1 & section_num == 10 & d ~= .

***Religion interactions
gen prot = 0
replace prot = 1 if relig == 1
gen prot1 = prot * u1
gen prot2 = prot * u2
gen prot3 = prot * u3
gen prot4 = prot * u4
gen prot5 = prot * u5
gen prot6 = prot * u6
gen prot7 = prot * u7
gen prot7_1 = prot * u8
gen prot8 = prot * onevstwo
gen prot9 = prot * largestakes
gen prot10 = prot * treatRpg
gen prot11 = prot * treatRge 
gen prot12 = prot * treatRdg 
gen prot13 = prot * treatRtp 
gen prot14 = prot * treatRrp 
gen prot15 = prot * treatRan 
gen prot16 = prot * treatRtr
gen prot16_1 = prot * treatRwa


gen cath = 0
replace cath = 1 if relig == 2
gen cath1 = cath * u1
gen cath2 = cath * u2
gen cath3 = cath * u3
gen cath4 = cath * u4
gen cath5 = cath * u5
gen cath6 = cath * u6
gen cath7 = cath * u7
gen cath7_1 = cath * u8
gen cath8 = cath * onevstwo
gen cath9 = cath * largestakes
gen cath10 = cath * treatRpg
gen cath11 = cath * treatRge 
gen cath12 = cath * treatRdg 
gen cath13 = cath * treatRtp 
gen cath14 = cath * treatRrp 
gen cath15 = cath * treatRan 
gen cath16 = cath * treatRtr
gen cath16_1 = cath * treatRwa

gen jewi = 0
replace jewi = 1 if relig == 3
gen jewi1 = jewi * u1
gen jewi2 = jewi * u2
gen jewi3 = jewi * u3
gen jewi4 = jewi * u4
gen jewi5 = jewi * u5
gen jewi6 = jewi * u6
gen jewi7 = jewi * u7
gen jewi7_1 = jewi * u8
gen jewi8 = jewi * onevstwo
gen jewi9 = jewi * largestakes
gen jewi10 = jewi * treatRpg
gen jewi11 = jewi * treatRge 
gen jewi12 = jewi * treatRdg 
gen jewi13 = jewi * treatRtp 
gen jewi14 = jewi * treatRrp 
gen jewi15 = jewi * treatRan
gen jewi16 = jewi * treatRtr
gen jewi16_1 = jewi * treatRwa

gen atag = 0
replace atag = 1 if relig == 4
gen atag1 = atag * u1
gen atag2 = atag * u2
gen atag3 = atag * u3
gen atag4 = atag * u4
gen atag5 = atag * u5
gen atag6 = atag * u6
gen atag7 = atag * u7
gen atag7_1 = atag * u8
gen atag8 = atag * onevstwo
gen atag9 = atag * largestakes
gen atag10 = atag * treatRpg
gen atag11 = atag * treatRge 
gen atag12 = atag * treatRdg 
gen atag13 = atag * treatRtp 
gen atag14 = atag * treatRrp 
gen atag15 = atag * treatRan
gen atag16 = atag * treatRtr
gen atag16_1 = atag * treatRwa

intreg d p prot1 prot2 prot3 prot4 prot5 prot6 prot7 prot7_1 prot8 prot9 prot10 prot11 prot12 prot13 prot14 prot15 prot16 prot16_1 cath1 cath2 cath3 cath4 cath5 cath6 cath7 cath7_1 cath8 cath9 cath10 cath11 cath12 cath13 cath14 cath15 cath16 cath16_1 jewi1 jewi2 jewi3 jewi4 jewi5 jewi6 jewi7 jewi7_1 jewi8 jewi9 jewi10 jewi11 jewi12 jewi13 jewi14 jewi15 jewi16 jewi16_1 atag1 atag2 atag3 atag4 atag5 atag6 atag7 atag7_1 atag8 atag9 atag10 atag11 atag12 atag13 atag14 atag15 atag16 atag16_1 , noconstant het(prot1 prot2 prot3 prot4 prot5 prot6 prot7 prot7_1 cath1 cath2 cath3 cath4 cath5 cath6 cath7 cath7_1 jewi1 jewi2 jewi3 jewi4 jewi5 jewi6 jewi7 jewi7_1 atag1 atag2 atag3 atag4 atag5 atag6 atag7 atag7_1) cluster(id)

test (prot10 = 0) (prot11 = 0) (prot12 = 0) (prot13 = 0) (prot14 = 0) (prot15 = 0) (prot16 = 0) (prot16_1) (cath10 = 0) (cath11 = 0) (cath12 = 0) (cath13 = 0) (cath14 = 0) (cath15 = 0) (cath16 = 0) (cath16_1) (jewi10 = 0) (jewi11 = 0) (jewi12 = 0) (jewi13 = 0) (jewi14 = 0) (jewi15 = 0) (jewi16 = 0) (jewi16_1) (atag10 = 0) (atag11 = 0) (atag12 = 0) (atag13 = 0) (atag14 = 0) (atag15 = 0) (atag16 = 0) (atag16_1)


*Are priming effects jointly equal across religions?
clear all
set mem 50m
set more off

use "/Users/gwf25/Dropbox/research/religion/final code/religion_all.dta"

//  Begin definition of variables

***Drop subjects who thought the experiment was about religion
gen id = _n
drop if id == 98 | id == 176 | id == 194 | id == 383

***Drop subjects who incorrectly completed the priming task. This includes subjects who leave more than half the responses blank. The following subjects
***all left at least questions #2-#7 blank in the sentence unscrambling task. 
drop if id==7 | id==719 | id==740 | id==762 | id==940

***An error led to some subjects seeing both the control and religion salient sentence unscrambling tasks. Here, we drop those subjects.
drop if prime_diff == 1

***"skipped" is a dummy variable for whether subjects skip the question that asks their religion. If they skip this question, we drop them from the sample 
***and if not, we assign a dummy variable to indicate the treatment group (religion salient or control) that subject belongs to.
gen skipped=0
replace skipped=1 if  s10q15==""
gen treatR=.
replace treatR=religion if skipped==0
drop if skipped==1

***Define religion
gen relig=.

***Note: 1 = protestant or other christian, 2 = catholic, 3 = jewish, 4 = agnostic/atheist
replace relig=1 if (s10q15=="Christian - Other (please specify below)" | s10q15=="Christian - Protestant (please specify denomination below)")
replace relig=2 if s10q15=="Christian - Catholic"
replace relig=3 if s10q15=="Jewish (Orthodox/Reformed/etc.)" | s10q15=="Jewish (Orthodox/Reform/etc.)"
replace relig=4 if (s10q15=="Agnostic" | s10q15=="Atheist")

***Drop Mormon/Othodox Christians from the sample
drop if s10q15sp == "Greek Orthodox"
drop if s10q15sp == "Russian Othrodox"
drop if s10q15sp == "greek orthodox"
drop if s10q15sp == "Orthodox Christian"
drop if s10q15sp == "Greek Orthdox"
drop if s10q15sp == "christian orthodox"
drop if s10q15sp == "Greek Orthodox Christian"
drop if s10q15sp == "Russian orthodox"
drop if s10q15sp == "Church of Jesus Christ of Latter Day Saints"
drop if s10q15sp == "Greek Orthodox"

// End of variables


****Create dependent variables to run in F-test****


***Wageoffer
rename m wageoffer

***Slope from regression of work cost on wages
***Create the cost, cXXX, for providing a certain amount of effort at eXXX. A certain monetary cost is associated with each level of output. So, we have:
***[eXXX, cXXX] = [(1,$0.00),(2,$0.04),(3,$0.08),(4,$0.16),(5,$0.24),(6,$0.32),(7,$0.40),(8,$0.48),(9,$0.60),(10,$0.72)]
gen c000 = .
replace c000 = 0 if e000 == 1
replace c000 = .04 if e000 == 2
replace c000 = .08 if e000 == 3
replace c000 = .16 if e000 == 4
replace c000 = .24 if e000 == 5
replace c000 = .32 if e000 == 6
replace c000 = .40 if e000 == 7
replace c000 = .48 if e000 == 8
replace c000 = .60 if e000 == 9
replace c000 = .72 if e000 == 10

gen c050 = .
replace c050 = 0 if e050 == 1
replace c050 = .04 if e050 == 2
replace c050 = .08 if e050 == 3
replace c050 = .16 if e050 == 4
replace c050 = .24 if e050 == 5
replace c050 = .32 if e050 == 6
replace c050 = .40 if e050 == 7
replace c050 = .48 if e050 == 8
replace c050 = .60 if e050 == 9
replace c050 = .72 if e050 == 10

gen c100 = .
replace c100 = 0 if e100 == 1
replace c100 = .04 if e100 == 2
replace c100 = .08 if e100 == 3
replace c100 = .16 if e100 == 4
replace c100 = .24 if e100 == 5
replace c100 = .32 if e100 == 6
replace c100 = .40 if e100 == 7
replace c100 = .48 if e100 == 8
replace c100 = .60 if e100 == 9
replace c100 = .72 if e100 == 10

gen c150 = .
replace c150 = 0 if e150 == 1
replace c150 = .04 if e150 == 2
replace c150 = .08 if e150 == 3
replace c150 = .16 if e150 == 4
replace c150 = .24 if e150 == 5
replace c150 = .32 if e150 == 6
replace c150 = .40 if e150 == 7
replace c150 = .48 if e150 == 8
replace c150 = .60 if e150 == 9
replace c150 = .72 if e150 == 10

gen c200 = .
replace c200 = 0 if e200 == 1
replace c200 = .04 if e200 == 2
replace c200 = .08 if e200 == 3
replace c200 = .16 if e200 == 4
replace c200 = .24 if e200 == 5
replace c200 = .32 if e200 == 6
replace c200 = .40 if e200 == 7
replace c200 = .48 if e200 == 8
replace c200 = .60 if e200 == 9
replace c200 = .72 if e200 == 10

gen c250 = .
replace c250 = 0 if e250 == 1
replace c250 = .04 if e250 == 2
replace c250 = .08 if e250 == 3
replace c250 = .16 if e250 == 4
replace c250 = .24 if e250 == 5
replace c250 = .32 if e250 == 6
replace c250 = .40 if e250 == 7
replace c250 = .48 if e250 == 8
replace c250 = .60 if e250 == 9
replace c250 = .72 if e250 == 10

gen c300 = .
replace c300 = 0 if e300 == 1
replace c300 = .04 if e300 == 2
replace c300 = .08 if e300 == 3
replace c300 = .16 if e300 == 4
replace c300 = .24 if e300 == 5
replace c300 = .32 if e300 == 6
replace c300 = .40 if e300 == 7
replace c300 = .48 if e300 == 8
replace c300 = .60 if e300 == 9
replace c300 = .72 if e300 == 10

gen c350 = .
replace c350 = 0 if e350 == 1
replace c350 = .04 if e350 == 2
replace c350 = .08 if e350 == 3
replace c350 = .16 if e350 == 4
replace c350 = .24 if e350 == 5
replace c350 = .32 if e350 == 6
replace c350 = .40 if e350 == 7
replace c350 = .48 if e350 == 8
replace c350 = .60 if e350 == 9
replace c350 = .72 if e350 == 10

gen c400 = .
replace c400 = 0 if e400 == 1
replace c400 = .04 if e400 == 2
replace c400 = .08 if e400 == 3
replace c400 = .16 if e400 == 4
replace c400 = .24 if e400 == 5
replace c400 = .32 if e400 == 6
replace c400 = .40 if e400 == 7
replace c400 = .48 if e400 == 8
replace c400 = .60 if e400 == 9
replace c400 = .72 if e400 == 10

***Drop the highest effort amount
drop c400

***In order to properly reshape the data, we must rename the effort and cost of effort at $0 and $0.50
rename e000 e0
rename e050 e50
rename c000 c0
rename c050 c50

***Create the corresponding wages for each effort choice
gen w0 = 0
gen w50 = .5
gen w100 = 1
gen w150 = 1.5
gen w200 = 2
gen w250 = 2.5
gen w300 = 3
gen w350 = 3.5

***Create the estimated regression parameter where beta=reciprocity
gen beta=.

replace id = _n

***Reshape the data so that we can regress cost of effort on all possible wages, by subject
reshape long c, i(id) j(w)

***Loop through all subjects and regress the effort on wage by each subject and save values of regression
***Note that some subjects did not do this section so we exclude them here. Only subjects numbered 263 through 689 did the gift exchange task.
quiet forvalues x = 263/689 {
reg c w if id ==`x'
replace beta=_b[w] if id ==`x'
}

***Reshape the data to its original form
reshape wide c, i(id) j(w)

***Public Good Contribution
rename s6 contribute

***Amount Given Away in Dictator Game
rename s5 giveaway

***Discount Rate

***Create the upper limit of the discount rate.
//gen r1=.
//replace r1= ln(ln(10.10/10)) if s2q1==1
//gen r2=.
//replace r2= ln(ln(10.25/10)) if s2q2==1
//gen r3=.
//replace r3= ln(ln(10.50/10)) if s2q3==1
//gen r4=.
//replace r4= ln(ln(10.75/10)) if s2q4==1
//gen r5=.
//replace r5= ln(ln(11/10)) if s2q5==1
//gen r6=.
//replace r6= ln(ln(11.25/10)) if s2q6==1
//gen r7=.
//replace r7= ln(ln(11.50/10)) if s2q7==1
//gen r8=.
//replace r8= ln(ln(12/10)) if s2q8==1
//gen r9=.
//replace r9= ln(ln(12.50/10)) if s2q9==1
//gen r10=.
//replace r10= ln(ln(13/10)) if s2q10==1
//gen r11=.
//replace r11= ln(ln(14/10)) if s2q11==1
//gen r12=.
//replace r12= ln(ln(15/10)) if s2q12==1

***Fill in the upper limit, rounding to 7 decimal places for now vs. 1 week choices.
gen r1=.
replace r1= -4.6101495 if s2q1==1
gen r2=.
replace r2= -3.7012512 if s2q2==1
gen r3=.
replace r3= -3.0202265 if s2q3==1
gen r4=.
replace r4= -2.6266454 if s2q4==1
gen r5=.
replace r5= -2.3506187 if s2q5==1
gen r6=.
replace r6= -2.1389110  if s2q6==1
gen r7=.
replace r7= -1.9678147 if s2q7==1
gen r8=.
replace r8= -1.7019834 if s2q8==1
gen r9=.
replace r9= -1.4999400 if s2q9==1
gen r10=.
replace r10= -1.3380214 if s2q10==1
gen r11=.
replace r11= -1.0892396 if s2q11==1
gen r12=.
replace r12= -0.9027205 if s2q12==1

***Choose the upper limit for the first time the subject makes the patient choice in the now vs. 1 week section.
gen reservationr1= min(r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12)

***Note that the number of missing observations for s2q1 through s2q24 (for those subjects who completed participated in the time section) is always zero.

***Fill in the upper limit, rounding to 7 decimal places for 1 week vs. 2 week choices.
gen r13=.
replace r13=-4.6101495 if s2q13==1
gen r14=.
replace r14= -3.7012512 if s2q14==1
gen r15=.
replace r15= -3.0202265 if s2q15==1
gen r16=.
replace r16= -2.6266454 if s2q16==1
gen r17=.
replace r17= -2.3506187 if s2q17==1
gen r18=.
replace r18= -2.1389110 if s2q18==1
gen r19=.
replace r19= -1.9678147 if s2q19==1
gen r20=.
replace r20= -1.7019834 if s2q20==1
gen r21=.
replace r21= -1.4999400 if s2q21==1
gen r22=.
replace r22= -1.3380214 if s2q22==1
gen r23=.
replace r23= -1.0892396 if s2q23==1
gen r24=.
replace r24= -0.9027205 if s2q24==1

***Choose the upper limit for the first time the subject makes the patient choice in the 1 week vs. 2 week section.
gen reservationr2=min(r13,r14,r15,r16,r17,r18,r19,r20,r21,r22,r23, r24)

***Each subject has an upper limit for the discount rate in now vs. 1 week and an upper limit for the discount rate in 1 week vs. two weeks. Rename these rateu_1 and rateu_2, respectively.
rename reservationr1 rateu_1
rename reservationr2 rateu_2
***Create a corresponding lower limit for each discount rate.
gen ratel_1=. 
gen ratel_2=.

***Fill in the values for the lower limit of the discount rate.
***Note that log(x) returns the natural log of ln(x) 
//replace ratel=. if rate==log(log(10.10/10))
//replace ratel= log(log(10.10/10)) if rate==log(log(10.25/10))
//replace ratel= log(log(10.25/10)) if rate==log(log(10.5/10))
//replace ratel= log(log(10.5/10)) if rate==log(log(10.75/10))
//replace ratel= log(log(10.75/10)) if rate==log(log(11/10))
//replace ratel= log(log(11/10)) if rate==log(log(11.25/10))
//replace ratel= log(log(11.25/10)) if rate==log(log(11.50/10))
//replace ratel= log(log(11.50/10)) if rate==log(log(12/10))
//replace ratel= log(log(12/10)) if rate==log(log(12.5/10))
//replace ratel= log(log(12.5/10)) if rate==log(log(13/10))
//replace ratel= log(log(13/10)) if rate==log(log(14/10))
//replace ratel= log(log(14/10)) if rate==log(log(15/10))
//replace ratel= log(log(15/10)) if rate==.

***Fill in the values for the lower limit of the discount rate for now vs. 1 week. This only assigns a value to those who took part in this section.
replace ratel_1=. if rateu_1 < -4.61 & s2q1 ~= .
replace ratel_1= -4.6101494 if rateu_1 < -3.7 & rateu_1 > -4.61  & s2q1 ~= .
replace ratel_1= -3.7012513 if rateu_1 < -3.02 & rateu_1 > -3.7  & s2q1 ~= .
replace ratel_1= -3.0202265 if rateu_1 < -2.62 & rateu_1 > -3.02 & s2q1 ~= .
replace ratel_1= -2.6266454 if rateu_1 < -2.35 & rateu_1 > -2.62 & s2q1 ~= .
replace ratel_1= -2.350618  if rateu_1 < -2.13 & rateu_1 > -2.35 & s2q1 ~= .
replace ratel_1= -2.1389110  if rateu_1 < -1.96 & rateu_1 > -2.13 & s2q1 ~= .
replace ratel_1= -1.9678147  if rateu_1 < -1.70 & rateu_1 > -1.96 & s2q1 ~= .
replace ratel_1= -1.7019834  if rateu_1 < -1.49 & rateu_1 > -1.70 & s2q1 ~= .
replace ratel_1= -1.4999400  if rateu_1 < -1.33 & rateu_1 > -1.49 & s2q1 ~= .
replace ratel_1= -1.3380214  if rateu_1 < -1.08 & rateu_1 > -1.33 & s2q1 ~= .
replace ratel_1= -1.0892396  if rateu_1 < -0.90 & rateu_1 > -1.08 & s2q1 ~= .
replace ratel_1= -0.9027205 if rateu_1 ==. & s2q1 ~= .

***Fill in the values for the lower limit of the discount rate for 1 week vs. 2 week. This only assigns a value to those who took part in this section.
replace ratel_2=. if rateu_2 < -4.61 & s2q1 ~= .
replace ratel_2= -4.6101494 if rateu_2 < -3.7 & rateu_2 > -4.61 & s2q1 ~= .
replace ratel_2= -3.7012513 if rateu_2 < -3.02 & rateu_2 > -3.7 & s2q1 ~= .
replace ratel_2= -3.0202265 if rateu_2 < -2.62 & rateu_2 > -3.02 & s2q1 ~= .
replace ratel_2= -2.6266454 if rateu_2 < -2.35 & rateu_2 > -2.62 & s2q1 ~= .
replace ratel_2= -2.350618  if rateu_2 < -2.13 & rateu_2 > -2.35 & s2q1 ~= .
replace ratel_2= -2.1389110  if rateu_2 < -1.96 & rateu_2 > -2.13 & s2q1 ~= .
replace ratel_2= -1.9678147  if rateu_2 < -1.70 & rateu_2 > -1.96 & s2q1 ~= .
replace ratel_2= -1.7019834  if rateu_2 < -1.49 & rateu_2 > -1.70 & s2q1 ~= .
replace ratel_2= -1.4999400  if rateu_2 < -1.33 & rateu_2 > -1.49 & s2q1 ~= .
replace ratel_2= -1.3380214  if rateu_2 < -1.08 & rateu_2 > -1.33 & s2q1 ~= .
replace ratel_2= -1.0892396  if rateu_2 < -0.90 & rateu_2 > -1.08 & s2q1 ~= .
replace ratel_2= -0.9027205 if rateu_2 ==. & s2q1 ~= .




***Risk Aversion

***Generate upper limit for risk with small amounts
gen risk1=.
replace risk1=(1.6*0.5-1) if s3q1==1
gen risk2=.
replace risk2=(2*0.5-1) if s3q2==1
gen risk3=.
replace risk3=(2.4*0.5-1) if s3q3==1
gen risk4=.
replace risk4=(2.8*0.5-1) if s3q4==1
gen risk5=.
replace risk5=(3.2*0.5-1) if s3q5==1
gen risk6=.
replace risk6=(3.6*0.5-1) if s3q6==1

***Choose the upper limit for the first time a subject chooses the risky asset with small amounts.
gen reservationrisk1= min(risk1,risk2,risk3,risk4,risk5,risk6)

***Generate upper limit for risk with large amounts
gen risk7=.
replace risk7=(160*0.5-100)/100 if s4q1==1
gen risk8=.
replace risk8=(200*0.5-100)/100 if s4q2==1
gen risk9=.
replace risk9=(240*0.5-100)/100 if s4q3==1
gen risk10=.
replace risk10=(280*0.5-100)/100 if s4q4==1
gen risk11=.
replace risk11=(320*0.5-100)/100 if s4q5==1
gen risk12=.
replace risk12=(360*0.5-100)/100 if s4q6==1

***Choose the upper limit for the first time a subject chooses the risky asset with large amounts.
gen reservationrisk2= min(risk7,risk8,risk9,risk10,risk11,risk12)

***risku_1 and risku_2 are the upper limits for risky choices with small and large stakes, respectively.
rename reservationrisk1 risku_1
rename reservationrisk2 risku_2
***Create variables for the lower limits.
gen riskl_1=.
gen riskl_2=.

***Assign values for the lower limit in small stakes. Only those who took participated in this section are assigned values.
replace riskl_1=. if risku_1 < -.2  & s4q1 ~= .
replace riskl_1=(1.6*0.5-1) if risku_1 == 0 & s4q1 ~= .
replace riskl_1=(2*0.5-1) if risku_1 > .1 & risku_1 < .3 & s4q1 ~= .
replace riskl_1=(2.4*0.5-1) if risku_1 > .3 & risku_1 < .5 & s4q1 ~= .
replace riskl_1=(2.8*0.5-1) if risku_1 > .5 & risku_1 < .7 & s4q1 ~= .
replace riskl_1=(3.2*0.5-1) if risku_1 > .7 & risku_1 < .9 & s4q1 ~= .
replace riskl_1=(3.6*0.5-1) if risku_1 == . & s4q1 ~= .

***Assign values for the lower limit in large stakes. Only those who took participated in this section are assigned values.
replace riskl_2=. if risku_2 < -.2  & s4q1 ~= .
replace riskl_2=(1.6*0.5-1) if risku_2 == 0 & s4q1 ~= .
replace riskl_2=(2*0.5-1) if risku_2 > .1 & risku_2 < .3 & s4q1 ~= .
replace riskl_2=(2.4*0.5-1) if risku_2 > .3 & risku_2 < .5 & s4q1 ~= .
replace riskl_2=(2.8*0.5-1) if risku_2 > .5 & risku_2 < .7 & s4q1 ~= .
replace riskl_2=(3.2*0.5-1) if risku_2 > .7 & risku_2 < .9 & s4q1 ~= .
replace riskl_2=(3.6*0.5-1) if risku_2 == . & s4q1 ~= .


***Anagrams Attempted
***The corresponding variable is named "anagramsattempted"

***Drop subjects who are not in our 4 religious groups
drop if relig == .

replace id = _n

***Create the dependent variables. When p_i = d_i, the data is point data. When p_i ~= d_i, the data is interval data (only discount rate and risk aversion)
rename contribute d1
gen p1 = d1
rename beta d2
gen p2 = d2
rename giveaway d3
gen p3 = d3
rename ratel_1 d4
rename rateu_1 p4
rename ratel_2 d5
rename rateu_2 p5
rename riskl_1 d6
rename risku_1 p6
rename riskl_2 d7
rename risku_2 p7
rename anagramsattempted d8
gen p8 = d8
*rename wageoffer d9
*gen p9 = d9
rename s6exp d9
gen p9 = d9

reshape long d p, i(id) j(section_num)

***Dummies for task type
gen u1 = 0 //contribute
replace u1 = 1 if section_num == 1 & d ~= .
gen u2 = 0 //beta
replace u2 = 1 if section_num == 2 & d ~= .
gen u3 = 0 //giveaway
replace u3 = 1 if section_num == 3 & d ~= .
gen u4 = 0 //TP
replace u4 = 1 if (section_num == 4 | section_num == 5) & (d ~= . | p ~= .)
gen u5 = 0 //RP
replace u5 = 1 if (section_num == 6 | section_num == 7) & (d ~= . | p ~= .)
gen u6 = 0 //AN
replace u6 = 1 if section_num == 8 & d ~= .
gen u7 = 0 //s6exp (public good expectation)
replace u7 = 1 if section_num == 9 & d ~= .

***Additional controls
gen onevstwo = 0
replace onevstwo = 1 if section_num == 5
gen largestakes = 0
replace largestakes = 1 if section_num == 7

***Treatment Dummies
gen treatRpg = 0
replace treatRpg = 1 if treatR == 1 & section_num == 1 & d ~= .
gen treatRge = 0
replace treatRge = 1 if treatR == 1 & section_num == 2 & d ~= .
gen treatRdg = 0
replace treatRdg = 1 if treatR == 1 & section_num == 3 & d ~= .
gen treatRtp = 0
replace treatRtp = 1 if treatR == 1 & (section_num == 4 | section_num == 5) & (d ~= . | p ~= .)
gen treatRrp = 0
replace treatRrp = 1 if treatR == 1 & (section_num == 6 | section_num == 7) & (d ~= . | p ~= .)
gen treatRan = 0
replace treatRan = 1 if treatR == 1 & section_num == 8 & d ~= .
gen treatRtr = 0
replace treatRtr = 1 if treatR == 1 & section_num == 9 & d ~= .

***Religion interactions
gen prot = 0
replace prot = 1 if relig == 1
gen prot1 = prot * u1
gen prot2 = prot * u2
gen prot3 = prot * u3
gen prot4 = prot * u4
gen prot5 = prot * u5
gen prot6 = prot * u6
gen prot7 = prot * u7
gen prot8 = prot * onevstwo
gen prot9 = prot * largestakes
gen prot10 = prot * treatRpg
gen prot11 = prot * treatRge 
gen prot12 = prot * treatRdg 
gen prot13 = prot * treatRtp 
gen prot14 = prot * treatRrp 
gen prot15 = prot * treatRan 
gen prot16 = prot * treatRtr

gen cath = 0
replace cath = 1 if relig == 2
gen cath1 = cath * u1
gen cath2 = cath * u2
gen cath3 = cath * u3
gen cath4 = cath * u4
gen cath5 = cath * u5
gen cath6 = cath * u6
gen cath7 = cath * u7
gen cath8 = cath * onevstwo
gen cath9 = cath * largestakes
gen cath10 = cath * treatRpg
gen cath11 = cath * treatRge 
gen cath12 = cath * treatRdg 
gen cath13 = cath * treatRtp 
gen cath14 = cath * treatRrp 
gen cath15 = cath * treatRan 
gen cath16 = cath * treatRtr

gen jewi = 0
replace jewi = 1 if relig == 3
gen jewi1 = jewi * u1
gen jewi2 = jewi * u2
gen jewi3 = jewi * u3
gen jewi4 = jewi * u4
gen jewi5 = jewi * u5
gen jewi6 = jewi * u6
gen jewi7 = jewi * u7
gen jewi8 = jewi * onevstwo
gen jewi9 = jewi * largestakes
gen jewi10 = jewi * treatRpg
gen jewi11 = jewi * treatRge 
gen jewi12 = jewi * treatRdg 
gen jewi13 = jewi * treatRtp 
gen jewi14 = jewi * treatRrp 
gen jewi15 = jewi * treatRan
gen jewi16 = jewi * treatRtr

gen atag = 0
replace atag = 1 if relig == 4
gen atag1 = atag * u1
gen atag2 = atag * u2
gen atag3 = atag * u3
gen atag4 = atag * u4
gen atag5 = atag * u5
gen atag6 = atag * u6
gen atag7 = atag * u7
gen atag8 = atag * onevstwo
gen atag9 = atag * largestakes
gen atag10 = atag * treatRpg
gen atag11 = atag * treatRge 
gen atag12 = atag * treatRdg 
gen atag13 = atag * treatRtp 
gen atag14 = atag * treatRrp 
gen atag15 = atag * treatRan
gen atag16 = atag * treatRtr

intreg d p prot1 prot2 prot3 prot4 prot5 prot6 prot7 prot8 prot9 prot10 prot11 prot12 prot13 prot14 prot15 prot16 cath1 cath2 cath3 cath4 cath5 cath6 cath7 cath8 cath9 cath10 cath11 cath12 cath13 cath14 cath15 cath16 jewi1 jewi2 jewi3 jewi4 jewi5 jewi6 jewi7 jewi8 jewi9 jewi10 jewi11 jewi12 jewi13 jewi14 jewi15 jewi16 atag1 atag2 atag3 atag4 atag5 atag6 atag7 atag8 atag9 atag10 atag11 atag12 atag13 atag14 atag15 atag16 , noconstant het(prot1 prot2 prot3 prot4 prot5 prot6 prot7 cath1 cath2 cath3 cath4 cath5 cath6 cath7 jewi1 jewi2 jewi3 jewi4 jewi5 jewi6 jewi7 atag1 atag2 atag3 atag4 atag5 atag6 atag7) cluster(id)

test (prot10 = 0) (prot11 = 0) (prot12 = 0) (prot13 = 0) (prot14 = 0) (prot15 = 0) (prot16 = 0) (cath10 = 0) (cath11 = 0) (cath12 = 0) (cath13 = 0) (cath14 = 0) (cath15 = 0) (cath16 = 0) (jewi10 = 0) (jewi11 = 0) (jewi12 = 0) (jewi13 = 0) (jewi14 = 0) (jewi15 = 0) (jewi16 = 0) (atag10 = 0) (atag11 = 0) (atag12 = 0) (atag13 = 0) (atag14 = 0) (atag15 = 0) (atag16 = 0)


keep if relig == 1 | relig == 2 | relig == 3 | relig == 4




*Protestant is now reference
intreg d p u1 u2 u3 u4 u5 u6 u7 onevstwo largestakes treatRpg treatRge treatRdg treatRtp treatRrp treatRan treatRtr cath1 cath2 cath3 cath4 cath5 cath6 cath7 cath8 cath9 cath10 cath11 cath12 cath13 cath14 cath15 cath16 jewi1 jewi2 jewi3 jewi4 jewi5 jewi6 jewi7 jewi8 jewi9 jewi10 jewi11 jewi12 jewi13 jewi14 jewi15 jewi16 atag1 atag2 atag3 atag4 atag5 atag6 atag7 atag8 atag9 atag10 atag11 atag12 atag13 atag14 atag15 atag16, noconstant het(u1 u2 u3 u4 u5 u6 u7 cath1 cath2 cath3 cath4 cath5 cath6 cath7 jewi1 jewi2 jewi3 jewi4 jewi5 jewi6 jewi7 atag1 atag2 atag3 atag4 atag5 atag6 atag7) cluster(id)

*are differences between prot and cath treatment effects jointly significant
test (cath10 = 0) (cath11 = 0) (cath12 = 0) (cath13 = 0) (cath14 = 0) (cath15 = 0) (cath16 = 0)
*are differences between prot and jewish treatment effects jointly significant
test (jewi10 = 0) (jewi11 = 0) (jewi12 = 0) (jewi13 = 0) (jewi14 = 0) (jewi15 = 0) (jewi16 = 0)

*Catholics are now reference
intreg d p u1 u2 u3 u4 u5 u6 u7 onevstwo largestakes treatRpg treatRge treatRdg treatRtp treatRrp treatRan treatRtr prot1 prot2 prot3 prot4 prot5 prot6 prot7 prot8 prot9 prot10 prot11 prot12 prot13 prot14 prot15 prot16 jewi1 jewi2 jewi3 jewi4 jewi5 jewi6 jewi7 jewi8 jewi9 jewi10 jewi11 jewi12 jewi13 jewi14 jewi15 jewi16 atag1 atag2 atag3 atag4 atag5 atag6 atag7 atag8 atag9 atag10 atag11 atag12 atag13 atag14 atag15 atag16, noconstant het(u1 u2 u3 u4 u5 u6 u7 prot1 prot2 prot3 prot4 prot5 prot6 prot7 jewi1 jewi2 jewi3 jewi4 jewi5 jewi6 jewi7 atag1 atag2 atag3 atag4 atag5 atag6 atag7) cluster(id)

*are differences between jewish and cath treatment effects jointly significant
test (jewi10 = 0) (jewi11 = 0) (jewi12 = 0) (jewi13 = 0) (jewi14 = 0) (jewi15 = 0) (jewi16 = 0)

*Atheists/Agnostics are now the reference
intreg d p u1 u2 u3 u4 u5 u6 u7 onevstwo largestakes treatRpg treatRge treatRdg treatRtp treatRrp treatRan treatRtr prot1 prot2 prot3 prot4 prot5 prot6 prot7 prot8 prot9 prot10 prot11 prot12 prot13 prot14 prot15 prot16 cath1 cath2 cath3 cath4 cath5 cath6 cath7 cath8 cath9 cath10 cath11 cath12 cath13 cath14 cath15 cath16 jewi1 jewi2 jewi3 jewi4 jewi5 jewi6 jewi7 jewi8 jewi9 jewi10 jewi11 jewi12 jewi13 jewi14 jewi15 jewi16, noconstant het(u1 u2 u3 u4 u5 u6 u7 prot1 prot2 prot3 prot4 prot5 prot6 prot7 prot8 prot9 prot10 prot11 prot12 prot13 prot14 prot15 prot16 cath1 cath2 cath3 cath4 cath5 cath6 cath7 jewi1 jewi2 jewi3 jewi4 jewi5 jewi6 jewi7) cluster(id)

test (prot10 = 0) (prot11 = 0) (prot12 = 0) (prot13 = 0) (prot14 = 0) (prot15 = 0) (prot16 = 0)
test (cath10 = 0) (cath11 = 0) (cath12 = 0) (cath13 = 0) (cath14 = 0) (cath15 = 0) (cath16 = 0)
test (jewi10 = 0) (jewi11 = 0) (jewi12 = 0) (jewi13 = 0) (jewi14 = 0) (jewi15 = 0) (jewi16 = 0)
